#pragma once
#include "../Ode.h"

namespace Skill
{
	namespace Ode
	{
		ref class DVector3;

		namespace Geometries
		{									
			public ref class DTriangle : DIUnmanagedPointer
			{
				INTERNAL_CLASS_DECLARATION(DTriangle,unsigned int);
			public:
				UNMANAGEDPOINTER_DECLARATION();

				property unsigned int A{unsigned int get(){return _This[0];}void set(unsigned int value){_This[0] = value;}}
				property unsigned int B{unsigned int get(){return _This[1];}void set(unsigned int value){_This[1] = value;}}
				property unsigned int C{unsigned int get(){return _This[2];}void set(unsigned int value){_This[2] = value;}}

			};

			public ref class DIndexBuffer sealed: DIUnmanagedPointer
			{
				INTERNAL_CLASS_DECLARATION(DIndexBuffer,unsigned int);

			private:
				int sizeInByte;
				int triangleCount;
			public:
				UNMANAGEDPOINTER_DECLARATION();

				///<summary>
				/// Helper class to handle unmanaged indexbuffer
				///</summary>						
				///<param name = "triangleCount">  Number of triangles</param>				
				DIndexBuffer(int triangleCount)
				{				
					this->triangleCount = triangleCount;
					sizeInByte = triangleCount * 12;
					_This = new unsigned int[IndexCount]();
				}
				void SetData(array<unsigned int>^ data,int startIndex,int lenght);
				void SetData(array<unsigned int>^ data);

				void SetTriangle(int triangleIndex,unsigned int a,unsigned int b,unsigned int c);
				void SetTriangle(int triangleIndex,DTriangle^ t);

				DTriangle^ GetReferenceTriangle(int triangleIndex);

				VALUE_PROP_DECLARATION_GET(int,IndexCount)
				VALUE_PROP_DECLARATION_GET(int,TriangleStride);
				VALUE_PROP_DECLARATION_GET(int,TriangleCount);
			};
		}
	}
}